package com.web.util;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class FileUtil {

	public static void saveFileFromInputSream(InputStream inputStream, String path, String fileName) throws IOException {
		String file = path + fileName;
		FileOutputStream fs = new FileOutputStream(file);
		byte[] buffer = new byte[1024 * 1024];
		int byteSum = 0;
		int byteRead = 0;
		while((byteRead = inputStream.read(buffer)) != -1) {
			byteSum += byteRead;
			fs.write(buffer, 0, byteRead);
			fs.flush();
		}
		fs.close();
		inputStream.close();
	}
}
